class: center, middle, inverse, title-slide .title[ # FIN7030: Times Series Financial Econometrics 2 ] .subtitle[ ## Meet the toolkit:
R
Git
Posit
Quarto … ] .author[ ### Barry Quinn ] .date[ ### 2023-02-02 ] --- layout: true <div class="my-footer"> <span> Barry Quinn CStat </span> </div> --- layout: true <div class="my-footer"><span>quinference.com</span></div> --- class: middle ## Course toolkit <br> .pull-left[ ### .gray[Course operation] .gray[ - Slack - Canvas - Teams - Github ] ] .pull-right[ ### .pink[Doing financial data science] - .pink[Programming:] - .pink[R] - .pink[Posit (Formerly RStudio)] - .pink[tidyverse] - .pink[Quarto] - .gray[Version control and collaboration:] - .gray[Git] - .gray[GitHub] ] --- ## Learning goals By the end of the course, you will be able to... -- - gain insight from data -- - gain insight from data, **reproducibly** -- - gain insight from data, reproducibly, **using modern programming tools and techniques** -- - gain insight from data, reproducibly **and collaboratively**, using modern programming tools and techniques -- - gain insight from data, reproducibly **(with literate programming and version control)** and collaboratively, using modern programming tools and techniques --- class: middle # Reproducible data analysis --- class:middle ## Reproducibility checklist .large[ What does it mean for a data analysis to be "reproducible"? ] Near-term goals: - Are the tables and figures reproducible from the code and data? - Does the code actually do what you think it does? - In addition to what was done, is it clear *why* it was done? Long-term goals: - Can the code be used for other data? - Can you extend the code to do other things? --- class: middle ## Toolkit for reproducibility - Scriptability `\(\rightarrow\)` R - Literate programming (code, narrative, output in one place) `\(\rightarrow\)` Quarto - Version control `\(\rightarrow\)` Git / GitHub --- class: middle ## R and Posit .pull-left[ <img src="data:image/png;base64,#../img/r-logo.png" width="25%" /> - R is an open-source statistical **programming language** - R is also an environment for statistical computing and graphics - It's easily extensible with *packages* ] .pull-right[ <img src="data:image/png;base64,#../img/rstudio-logo.png" width="50%" /> - Posit is a convenient interface for R called an **IDE** (integrated development environment), e.g. *"I write R code in the Posit IDE"* - Posit is not a requirement for programming with R, but it's very commonly used by R programmers and data scientists ] --- class: inverse ## R packages - **Packages** are the fundamental units of reproducible R code. They include reusable R functions, the documentation that describes how to use them, and sample data<sup>1</sup> - As of September 2022, there are over near 20,000 R packages available on **CRAN** (the Comprehensive R Archive Network)<sup>2</sup> - We're going to work with a small (but important) subset of these! .footnote[ <sup>1</sup> Wickham and Bryan, [R Packages](https://r-pkgs.org/). <sup>2</sup> [CRAN contributed packages](https://cran.r-project.org/web/packages/). ] --- ## Tour: R and Posit <img src="data:image/png;base64,#../img/tour-r-rstudio.png" width="80%" /> --- ## A short list (for now) of R essentials - Functions are (most often) verbs, followed by what they will be applied to in parentheses: -- - Packages are installed with the `install.packages` function and loaded with the `library` function, once per session: --- class:middle ## R essentials (continued) - Columns (variables) in data frames are accessed with `$`: .small[ ] -- - Object documentation can be accessed with `?` --- class: middle ## tidyverse .pull-left[ <img src="data:image/png;base64,#../img/tidyverse.png" width="99%" /> ] .pull-right[ .center[.large[ [tidyverse.org](https://www.tidyverse.org/) ]] - The **tidyverse** is an opinionated collection of R packages designed for data science - All packages share an underlying philosophy and a common grammar ] --- class: middle # Quarto .center[.large[ [quarto.org](https://quarto.org`/) ]] - Easy to use interface - Quarto Scientific Publishing Software provides a user-friendly interface that makes it easy to create, edit, and publish scientific documents. - Comprehensive content management - Quarto Scientific Publishing Software allows users to easily manage their content, including text, images, and multimedia. - Automated workflow - Quarto Scientific Publishing Software automates the publishing process, from content creation to publication. - Customizable templates - Quarto Scientific Publishing Software allows users to customize templates to ensure consistency in their documents. - Secure platform - Quarto Scientific Publishing Software provides a secure platform with strong encryption and authentication systems to protect user data. .fancy[More on Quarto in next lecture] --- class:middle ## Git and GitHub .pull-left[ <img src="data:image/png;base64,#../img/git-logo.png" width="25%" /> - Git is a version control system -- like “Track Changes” features from Microsoft Word, on steroids - It's not the only version control system, but it's a very popular one ] .pull-right[ <img src="data:image/png;base64,#../img/github-logo.png" width="25%" /> - GitHub is the home for your Git-based projects on the internet -- like DropBox but much, much better - We will use GitHub as a platform for web hosting and collaboration (and as our course management system!) ] --- class: middle ## Versioning <img src="data:image/png;base64,#../img/lego-steps.png" width="70%" style="display: block; margin: auto;" /> --- class: middle ## Versioning ### with human readable messages <img src="data:image/png;base64,#../img/lego-steps-commit-messages.png" width="60%" style="display: block; margin: auto;" /> --- class: middle ## Why do we need version control? <img src="data:image/png;base64,#../img/phd_comics_vc.gif" width="35%" style="display: block; margin: auto;" /> --- class: middle ## How will we use Git and GitHub? <img src="data:image/png;base64,#../img/whole-game-01.png" width="100%" /> --- class: middle ## How will we use Git and GitHub? <img src="data:image/png;base64,#../img/whole-game-02.png" width="100%" /> --- class: middle ## How will we use Git and GitHub? <img src="data:image/png;base64,#../img/whole-game-03.png" width="100%" /> --- class: middle ## How will we use Git and GitHub? <img src="data:image/png;base64,#../img/whole-game-04.png" width="100%" /> --- class: middle # Git and GitHub tips - There are millions of git commands -- ok, that's an exaggeration, but there are a lot of them -- and very few people know them all. 99% of the time you will use git to add, commit, push, and pull. -- - We will be doing Git things and interfacing with GitHub through Posit, but if you google for help you might come across methods for doing these things in the command line
-- skip that and move on to the next resource unless you feel comfortable trying it out. -- - Interested in command line data science see [https://www.datascienceatthecommandline.com/](https://www.datascienceatthecommandline.com/) -- - There is a great resource for working with git and R: [happygitwithr.com](http://happygitwithr.com/). Some of the content in there is beyond the scope of this course, but it's a good place to look for help. --- class: middle .your-turn[ **Difficulty: medium** - Create a GitHub account - Verify your GitHub email - Adjust your GitHub settings for a more pleasant GitHub experience - Settings > Emails > Uncheck "Keep my email address private" - Settings > Emails > Update name and photo ] --- class: middle .your-turn[ **Difficulty: medium** - Go to [Github.com](https://github.com) and create an account using your QUB credentials. - Login to the [Slack channel](https://join.slack.com/t/rethinkingeco-3ss9716/shared_invite/zt-12nfdfr7o-XAy2Ef1knAKXgUNo2kWw3w) and share your username with the lecturer. - Create a new repository on Github called 'first repo' - Create a new project on your Q-RaP Posit Cloud account by using the url of your first repo - create a Rmarkdown file in new RStudio project space. - Knit the Rmarkdown file to a html file. - Commit and push change to your Github repo. ]